<template>
  <div class="my_div">
    <img
      :src="imgurl"
      alt=""
    />
    <p :style="{ backgroundColor: colors }" @click="dogBtn">
      {{dogname}}
    </p>
  </div>
</template>

<script>
export default {

   props: ['imgurl', 'dogname'],
   
  data() {
    return {
      colors: "",
      
    };
  },
  methods: {
    dogBtn() {
      this.colors = `rgb( ${Math.floor(Math.random() * 256)},
                          ${Math.floor(Math.random() * 256)},
                          ${Math.floor(Math.random() * 256)} )`
      this.$emit("love",this.dogname);
    },
  },
};
</script>

<style>
.my_div {
  width: 400px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
}
</style>